package com.leyou.controller;

import com.leyou.server.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class ItemController {
    @Autowired
    private ItemService itemService;

    @PostMapping("/save")
    public Long save(@RequestParam("id") Long id){
        return itemService.saveItem(id);
    }
    /**
     * 扣减库存
     */
    @PutMapping("/stock/minus")
    public ResponseEntity<Void> minusStock(
            @RequestBody Map<Long,Integer> paramap
            ){
         itemService.minusStock(paramap);
         return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
    }


}
